package com.fyl.beans;

import com.alibaba.druid.pool.DruidDataSource;
import com.fyl.dao.UserDao;
import com.fyl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

//@Component
public class OtherBean {

    //@Bean("dataSource")
    public DataSource dataSource(@Value("${jdbc.driver}") String driver,
                                 @Autowired @Qualifier("userDao2") UserDao userDao,
                                 UserService userService) {
        DruidDataSource dataSource = new DruidDataSource();
        System.out.println("driver = " + driver);
        System.out.println("userDao dataSource= " + userDao);
        System.out.println("userService dataSource= " + userService);
        //设置四个参数
        return dataSource;
    }
}
